package org.summer.lawyer.controller.admin;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.summer.common.core.domain.R;
import org.summer.common.mybatis.core.page.TableDataInfo;
import org.summer.common.web.core.BaseController;
import org.summer.lawyer.domain.bo.spuorder.SpuOrderIncomeStatBo;
import org.summer.lawyer.domain.bo.spuorder.SpuOrderStatBo;
import org.summer.lawyer.domain.vo.spuorder.SpuOrderIncomeStatVo;
import org.summer.lawyer.domain.vo.spuorder.SpuOrderIncomeTotalStatVo;
import org.summer.lawyer.domain.vo.spuorder.SpuOrderStatVo;
import org.summer.lawyer.service.ISpuOrderService;

/**
 * 订单统计相关接口
 *
 * @author summer
 * @date 2024-06-20
 */
@Tag(name = "后台相关接口", description = "订单统计相关接口")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/lawyer/orderStat")
public class OrderStatController  extends BaseController {

    private final ISpuOrderService spuOrderService;

    @SaCheckPermission("stat:sales:list")
    @GetMapping("/getSpuOrderStat")
    public TableDataInfo<SpuOrderStatVo> getSpuOrderStat(SpuOrderStatBo bo){
        return spuOrderService.selectSpuOrderStatVo(bo);
    }

    @SaCheckPermission("stat:income:list")
    @GetMapping("/spuOrderIncomeStat")
    public TableDataInfo<SpuOrderIncomeStatVo> getSpuOrderIncomeStat(SpuOrderIncomeStatBo bo){
        return TableDataInfo.build(spuOrderService.selectSpuOrderIncomeStatVoList(bo));
    }

    @SaCheckLogin
    @GetMapping("/spuOrderIncomeTotalStatVo")
    public R<SpuOrderIncomeTotalStatVo> getSpuOrderIncomeTotalStatVo(){
        return R.ok(spuOrderService.selectSpuOrderIncomeTotalStatVo());
    }
}
